﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Popup_DispatchCancelReward : Popup_Base
{
	public Transform memberObjectListTrans;
	public GameObject[] memberObjectList;

    public override void AwakeInit()
    {
    }

    public override void StartInit()
    {
    }

    public override void UpdateScene()
    {
    }

    //public override void UpdateTouch()    // 정의 하면 ButtonTouch() 사용 불가
    //{
    //}

    public virtual void ButtonTouch(Collider collider)  // 버튼 터치 (터치 시작 끝 같은 오브젝트일때 터치 끝 시점에 호출)
    {
    }

    public override void BackButton()
    {
    }

	public void SetDispatchMemberInfos(int[][] dispatchMemberList)
	{
		int i=0;
		foreach(int[] memberId in dispatchMemberList)
		{
			foreach(KeyValuePair<string, MemberModel> pair in UserData.Instance.userModel.members_dic)
			{
				if( pair.Key.Equals(memberId[0].ToString()) )
				{
					Debug.LogError(memberId);
					Transform levelObj = memberObjectList[i].transform.FindChild("level");
					if( levelObj != null )
						levelObj.GetComponent<UILabel>().text = string.Format("LV {0}", pair.Value.level);
					Transform nameObj = memberObjectList[i].transform.FindChild("name");
					if( nameObj != null )
						nameObj.GetComponent<UILabel>().text = TextController.GetStringWithId(string.Format("charName{0}", pair.Value.name));
					Transform expObj = memberObjectList[i].transform.FindChild("exp");
					if( expObj != null )
						expObj.GetComponent<UILabel>().text = string.Format("+{0}", memberId[1]);
					
					memberObjectList[i++].SetActive(true);
				}
			}
		}

		if( dispatchMemberList.Length < 7 )
		{
			memberObjectListTrans.localPosition = new Vector3(620f-((dispatchMemberList.Length-1)*200f), 0f, 0f);
		}
	}

	public void ClosePopup()
	{
		PopupManager.PopPopup();
	}
}